package org.hzz.api.coupon;

import io.gitee.pkmer.convention.page.PageResponse;
import io.gitee.pkmer.convention.page.query.PageQuery;
import io.gitee.pkmer.convention.result.Result;
import io.swagger.v3.oas.annotations.Parameter;
import org.hzz.promotions.types.req.AddCouponReq;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.hzz.promotions.types.req.CouponPageQuery;
import org.hzz.promotions.types.req.IssueCouponReq;
import org.hzz.promotions.types.vo.CouponPageVo;
import org.hzz.promotions.types.vo.CouponVo;
import org.hzz.promotions.types.vo.ShowCouponVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * <a href = "https://gitee.com/pkmer/sonatype-central-publisher">Code Repository</a>
 * At 2024/8/29
 */
@RequestMapping("/coupons")
public interface CouponApi {

    @ApiResponse
    @Operation(description = "新增优惠券")
    @PostMapping
    Result<String> saveCoupon(@Validated @RequestBody AddCouponReq addCouponReq);

    @ApiResponse
    @Operation(description = "获取优惠券")
    @GetMapping("/{id}")
    Result<CouponVo> getCoupon(
            @Parameter(description = "优惠券id")
            @PathVariable
            String id);


    @ApiResponse
    @Operation(description = "分页查询")
    @GetMapping("/pages")
    Result<PageResponse<CouponPageVo>> pageQuery(
            @Validated @RequestBody CouponPageQuery pageQuery);

    @ApiResponse
    @Operation(description = "发放优惠券")
    @PostMapping("/{id}/issue")
    Result<Void> beginIssue(
            @Parameter(description = "优惠券id")
            @PathVariable String id,
            @RequestBody IssueCouponReq issueCouponReq);

    @Operation(description = "暂停发送优惠券")
    @PostMapping("/{id}/pause")
    Result<Void> pauseCoupon(
            @Parameter(description = "优惠券id")
            @PathVariable
            String id);

    @Operation(description = "删除优惠券")
    @PostMapping("/{id}/delete")
    Result<Void> deleteCoupon(
            @Parameter(description = "优惠券id")
            @PathVariable
            String id);

    @ApiResponse
    @Operation(description = "更新优惠券")
    @PostMapping("/{id}/update")
    Result<Void> updateCoupon(
            @Parameter(description = "优惠券ID")
            @PathVariable String id,
            @RequestBody AddCouponReq addCouponReq);

    @Operation(description = "展示给用户可手动领取的优惠券")
    @GetMapping("/list")
    Result<PageResponse<ShowCouponVo>> listCoupon(
            @RequestBody
            PageQuery pageQuery);
}
